home *** CD-ROM | disk | FTP | other *** search
/ Chip 2006 June / CHIP 2006-06.2.iso / program / freeware / Democracy-0.8.2.exe / xulrunner / python / databasehelper.py < prev    next >
Encoding:
Python Source  |  2006-04-10  |  468 b   |  13 lines

  1. # PyRex has no lambda, so we need this separated
  2. #
  3. # It takes in a Python style sort function that returns -1 for x<y, 0
  4. # for equal, and 1 for x>y and turns it into a STL style sort function
  5. # that returns true for x<y and false otherwise.
  6. #
  7. # It also changes the function to compare the second value in the
  8. # tuple instead of comparing x and y direction, so that we can use it
  9. # in our database
  10. def pysort2dbsort(func):
  11.     return lambda x, y:func(x[1],y[1]) == -1
  12.  
  13.